Strict

Import agfx

Global myTmpScreen:TTmpScreen

Class TAgfx_test_app Extends TFramework

	Method OnCreate:Int()
		
		'DEVICE.SetFps(30)		' default FPS is 60
		
		Super.OnCreate()
				
		IMAGES.Load("stick_bkg.png","STICK_BKG")
		IMAGES.Load("stick_front.png","STICK_FRONT")
		
		
		myTmpScreen = New TTmpScreen		
		myTmpScreen.Prepare()
		
		Return 0
	End
	
End

Class TMyVirtualStick Extends TVirtualStick
	
End Class

Class TTmpScreen Extends TScreen
	
	Field VStick:TVirtualStick = New TVirtualStick()

	' START when app is created
	Method Start:Void()
		Self.VStick.SetRing(100, DeviceHeight()-100, 40)
		Self.VStick.SetStick(0, 0, 16)
		Self.VStick.SetDeadZone(0.3)
		Self.VStick.SetTriggerDistance(1)
		Self.VStick.SetSkin("STICK_BKG","STICK_FRONT")
		
	End
	
	' main app logic loop update
	Method Update:Void()
		If MOUSE.Hit() Then
			Self.VStick.StartTouch(MOUSE.x, MOUSE.y, 0)
		EndIf
		
		If MOUSE.Down() Then
			Self.VStick.UpdateTouch(MOUSE.x, MOUSE.y, 0)
		EndIf
		
		If MOUSE.Up() Then
			Self.VStick.StopTouch(0)
		EndIf
	End
	
	' main app render loop
	Method Render:Void()
		Cls
		
		Self.VStick.Render()
		
		' some test info
		DrawText("angle = "+Self.VStick.GetAngle(), 10, 10)
		DrawText("vel   = "+Self.VStick.GetVelocity(), 10, 30)
		DrawText("dx    = "+Self.VStick.GetDX(), 10, 50)
		DrawText("dy    = "+Self.VStick.GetDY(), 10, 70)

		
	End
End

